//Rectangle.cpp
//Contains the function definitions for the Rectangle class

#include "Rectangle.h"
#include <iostream>

using namespace std;

Rectangle::Rectangle(const float &p_X, const float &p_Y, float wid, float len)
	: Shape(p_X, p_Y)
{
	setLength(len);
	setWidth(wid);
	setArea(len, wid);
	setPerim(len, wid);
	setDistance();
}

void Rectangle::setLength(float len)
{
	if (len >= 0.0)
		length = len;
	else
		throw invalid_argument("The length must be greater than zero.");
}

float Rectangle::getLength() const
{
	return length;
}

void Rectangle::setWidth(float wid)
{
	if (wid >= 0.0)
		width = wid;
	else
		throw invalid_argument("The width must be greater than zero.");
}

float Rectangle::getWidth() const
{
	return width;
}

void Rectangle::setArea(float len, float wid)
{
	R_area = len * wid;
}

float Rectangle::getArea() const
{
	return R_area;
}

void Rectangle::setPerim(float len, float wid)
{
	R_perimeter = 2 * len + 2 * wid;
}

float Rectangle::getPerim() const
{
	return R_perimeter;
}

float Rectangle::area() const
{
	return getArea();
}

float Rectangle::perimeter() const
{
	return getPerim();
}

float Rectangle::volume() const
{
	return 0.0;
}

ostream& operator<< (ostream &out, Shape &shape)
{
	out << "Base Area: " << shape.area() << endl
		<< "Base Perimeter: " << shape.perimeter() << endl
		<< "Volume: " << shape.volume() << endl
		<< "Position:" << endl
		<< "	X: " << shape.getX() << endl
		<< "	Y: " << shape.getY() << endl
		<< "Distance from Origin: " << shape.distance() << endl;

	return out;
}
